import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { createPage, base } from 'nc-lightapp-front';
import "./index.less"
// import { isEmpty } from "../utill"
import _ from 'lodash-es'

/**
 * @功能: 新增按钮的组件
 * @作者：Mr.sha
 * @日期：2022-05-26
 */
export default class ButtonAdd extends Component{
    constructor(props){
        super(props);
        this.state = {
            // 按钮显示的字符串
            showVal: props.showVal,
        }
    }

    /**
     * @功能: 新增
     * @作者：Mr.sha
     * @日期：2022-05-26
     */
    handleAddBag() {
        let params = {
            testParam: ""
        }
        if(this.props && this.props.handleAddBag){
            this.props.handleAddBag(params);
        }
    }

    render() {
        let multiLang = null;
        if(this.props && this.props.MutiInit && this.props.MutiInit.getIntl){
            multiLang = this.props.MutiInit.getIntl(2011); 
        }
        return (
            <div className='button-add' onClick={() => {this.handleAddBag()}}>
                {/* 加号图标 */}
                <div className = "button-add-icon"></div>
                {/* 按钮的显示字符串 */}
                <span className = "button-add-info">{_.isEmpty(this.state.showVal) ? multiLang.get("insert_invoice_bag") : this.state.showVal}</span>
            </div>
        )
    }
}
ButtonAdd = createPage({
    mutiLangCode: '2011'
})(ButtonAdd);

ReactDOM.render(<ButtonAdd />, document.querySelector('#app'))